package alfred.storage;

import org.zeromq.ZFrame;
import org.zeromq.ZMsg;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 */
public class MemoryMessagesStorage implements Storage<ZFrame, ZMsg> {
    private final ConcurrentMap<ZFrame, ZMsg> data = new ConcurrentHashMap<ZFrame, ZMsg>();

    @Override
    public void put(ZFrame key, ZMsg value) {
        data.put(key, value);
    }

    @Override
    public ZMsg get(ZFrame key) {
        return data.get(key);
    }

    @Override
    public boolean remove(ZFrame key) {
        return data.remove(key) != null;
    }
}
